home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / source / cardpkg_1.3.lha / CardPkg / CardVImages.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-19  |  4.1 KB  |  145 lines

  1. /************************************************************
  2.  
  3.     TML's C Language Card Image Package  v1.1
  4.     January, 1993
  5.     Todd M. Lewis             (919) 776-7386
  6.     2601 Piedmont Drive
  7.     Sanford, NC  27330-9437
  8.     USA
  9. ************************************************************/
  10.  
  11. #include <exec/types.h>
  12. #include <intuition/intuition.h>
  13. #include <graphics/gfxbase.h>
  14. #include <graphics/gfxmacros.h>
  15. #include "CardVImages.h"
  16. #include "Cards.h"
  17.  
  18. #ifdef AZTEC_C
  19.   #include <functions.h>
  20. #endif
  21. #ifdef __SASC
  22.   #include <clib/graphics_protos.h>
  23. #endif
  24.  
  25. /**********************************************************************
  26. CardVBrush.c contains an array of UWORDs which contains the
  27. bitmap data for a deck of playing cards layed out in four rows.
  28. In all 56 cards are defined in the following order:
  29.  
  30.      SpadeA..SpadeK,     Joker,
  31.      DiamondA..DiamondK, Back,
  32.      ClubA..ClubK,       Blank,
  33.      HeartA..HeartK,     Black
  34.  
  35. Each card is 38 bits wide and 32 bits high, but the edges of the
  36. cards overlap by one bit (pixel), so the total bitmap is
  37. 519(h)x125(v)x2 planes deep.  In addition, another bitplane is
  38. defined which has the same shape as the 2 mentioned above, but
  39. with all the pixels within the cards turned on. This bitplane is
  40. used as a mask with BltMaskBitMapRastPort() to round off the
  41. corners of the cards when they are copied.
  42.  
  43. MAKE SURE THE CardVBrush DATA GET LOADED INTO CHIP RAM!  You may
  44. have to edit CardVBrush.c to add the "__chip" keyword, or you
  45. may have to use a link option, or run the ATOM facility on the
  46. final executable to make it load into chip ram.
  47.  
  48. The cards were designed with the following pen colors:
  49.  
  50.   pen | red  green blue
  51.   ----+----------------
  52.     0 |   0     4    12   (Blue)
  53.     1 |   0     0     0   (Black)
  54.     2 |  14    12    10   (Creamy White)
  55.     3 |  15     8     0   (Rusty Red)
  56.  
  57. **********************************************************************/
  58.  
  59. #include "CardVBrush.c"
  60.  
  61. struct  Image CardVBrushimage =
  62.  {
  63.    0,0,
  64.    519 , 125 , 3 ,
  65.    &CardVBrush[0],
  66.    0x1f,0x00,
  67.    NULL,
  68.  };
  69.  
  70. extern struct GfxBase *GfxBase;
  71.  
  72. BOOL ShowVCard( struct RastPort *rp, CardID_t Card, WORD dx, WORD dy )
  73.   {
  74.     static struct BitMap bm;
  75.     static BOOL  bmInit = FALSE;
  76.     static UWORD *mask;
  77.     WORD suit, rank,x,y;
  78.  
  79.     if (!bmInit)
  80.       {
  81.         PLANEPTR tmp;
  82.         InitBitMap( &bm, 2L, 519L, 125L);
  83.         bm.Planes[0] = (PLANEPTR)&CardVBrush [ 0 ];
  84.         bm.Planes[1] = (PLANEPTR)&CardVBrush1[ 0 ];
  85.         mask         =           &CardVBrush2[ 0 ];
  86.  
  87.         /** Black and White are reversed prior to v35, so swap planes. **/
  88.         if ( CardColorSwapping && GfxBase->LibNode.lib_Version < 35 )
  89.           {
  90.             tmp = bm.Planes[0];
  91.                   bm.Planes[0] = bm.Planes[1];
  92.                                  bm.Planes[1] = tmp;
  93.           }
  94.         bmInit = 1;
  95.       }
  96.  
  97.     if ( Card == CARD_NONE ) /* Erase the card */
  98.       {
  99.         BYTE FgPen, DrawMode;
  100.         UBYTE Mask;
  101.         FgPen    = rp->FgPen;
  102.         DrawMode = rp->DrawMode;
  103.         Mask     = rp->Mask;
  104.         SetAPen( rp, 0 );
  105.         SetDrMd( rp, JAM1 );
  106.         SetWrMsk(rp, 0xff );
  107.         RectFill(rp, dx, dy, dx+CARD_V_WIDTH-1, dy+CARD_V_HEIGHT-1 );
  108.         SetWrMsk(rp, Mask );
  109.         SetDrMd( rp, DrawMode );
  110.         SetAPen( rp, FgPen );
  111.         return TRUE;
  112.       }
  113.  
  114.     if ( !(rank = CardRank( Card )) || !(suit = CardSuit( Card )) )
  115.       return FALSE;
  116.  
  117.     if ( suit == SUIT_SPECIAL )
  118.         {
  119.           x = 13;
  120.           y = rank - 1;
  121.         }
  122.       else
  123.         {
  124.           x = rank - 1;
  125.           y = suit - 1;
  126.         }
  127.  
  128.     BltMaskBitMapRastPort(
  129.        &bm,                                     /* Source BitMap */
  130.        x * (CARD_V_WIDTH -  1L),                /* Source X      */
  131.        y * (CARD_V_HEIGHT - 1L),                /* Source Y      */
  132.        rp,                                      /* destRastPort  */
  133.        dx, dy,                                  /* destX, destY  */
  134.        CARD_V_WIDTH, CARD_V_HEIGHT,             /* sizeX, sizeY  */
  135.        0x00E0,                                  /* minterm       */
  136.        (APTR)mask                               /* bltMask       */
  137.        );
  138.  
  139.     return TRUE;
  140.     }
  141.  
  142.  
  143.  
  144.  
  145.